const useDictStore = defineStore("dict", {
  state: () => ({
    dict: [
      {
        key: "orderAttrs",
        value: {
          Color: "颜色",
          CompanyName: "公司名称",
          CountAttrs: "属性数量",
          Deleted: "是否删除",
          DoorLeafBarCode: "门叶柱编号",
          DoorLeafSize: "门叶尺寸",
          DoorPocketBarCode: "口袋门柱编号",
          DoorPocketRequire: "口袋门需求",
          DoorPocketSize: "口袋门尺寸",
          DoorPocketType: "口袋门类型",
          DoorwaySize: "门道尺寸",
          FinishTime: "完成时间",
          GateType: "门类型",
          InputRemark: "用户输入备注",
          IsCancelOver: "是否取消",
          IsFinish: "是否已完成",
          IsOrderOverTime: "订单是否超时",
          IsOverTime: "是否超时",
          IsReturn: "是否交还",
          IsShow: "是否展示",
          LatestTrackInfo: "最新工序信息",
          LeafCount: "门叶数量",
          LineCount: "门线数量",
          LineType: "门线类型",
          Mark: "标记",
          MaterialQuality: "材料质量",
          Mobile: "风铃",
          NonTrackList: "无工序列表",
          OMarkDescription: "标记描述",
          OMarkStatus: "标记状态",
          OMarkStatusName: "标记状态名",
          OrderClerkName: "订单接单人",
          OrderRemark: "订单备注",
          OrderTime: "接单时间",
          OverTimeName: "超时名称",
          PieceCount: "碎片数量",
          PocketCount: "门袋数量",
          ProduceCode: "生产编号",
          QuantityUnit: "质量单位",
          Remark: "备注",
          RemarkView: "动态备注",
          SalesmanName: "订单销售员",
          SamplePicture: "订单缩略图",
          Status: "订单状态",
          StatusName: "状态名称",
          SubCustomerName: "子客户名称",
          Technique: "技术",
          TotalDays: "总用时（天）",
          TrackList: "工序进度",
          Type: "系列",
          Urgent: "是否加急",
          Veneer: "胶合板",
          nField: "自定义属性",
          Field1: "门型",
          Field2: "颜色",
          Field3: "开向",
          Field4: "门总高",
          Field5: "门总宽",
          Field6: "门高",
          Field7: "子客户",
          Field8: "包边",
          Field9: "拉手",
          Field10: "墙厚",
          Field11: "气窗工艺",
          Field12: "气窗款式",
          Field13: "工艺厚度",
          Field14: "要求一",
          Field15: "要求二",
        },
      },
    ],
  }),
  actions: {
    // 获取字典
    getDict(_key) {
      if (_key == null && _key == "") {
        return null;
      }
      try {
        for (let i = 0; i < this.dict.length; i++) {
          if (this.dict[i].key == _key) {
            return this.dict[i].value;
          }
        }
      } catch (e) {
        return null;
      }
    },
    // 设置字典
    setDict(_key, value) {
      if (_key !== null && _key !== "") {
        this.dict.push({
          key: _key,
          value: value,
        });
      }
    },
    // 删除字典
    removeDict(_key) {
      var bln = false;
      try {
        for (let i = 0; i < this.dict.length; i++) {
          if (this.dict[i].key == _key) {
            this.dict.splice(i, 1);
            return true;
          }
        }
      } catch (e) {
        bln = false;
      }
      return bln;
    },
    // 清空字典
    cleanDict() {
      this.dict = new Array();
    },
    // 初始字典
    initDict() {},
  },
});

export default useDictStore;
